<template>
    <div class="login-main">
        <img class="login-bg" src="../assets/img/login-1.jpg" alt="">

        <div class="login-form">
            <div class="login-form-left">
                <img class="" src="../assets/img/login-1.jpg" alt="">
            </div>
            <div class="login-form-right">
                <el-form label-position="left" :model="loginForm">
                    <div class="login-form-title">唯达宁在线客服系统</div>
                    <el-form-item>
                        <el-input prefix-icon="el-icon-user-solid" type="text" placeholder="请输入用户名"
                            v-model="loginForm.username"></el-input>
                    </el-form-item>
                    <el-form-item>
                        <el-input prefix-icon="el-icon-lock" type="password" placeholder="请输入密码"
                            v-model="loginForm.password"></el-input>
                    </el-form-item>
                    <el-button class="loginBtn" type="primary" :loading="loginForm.loading" @click="loginBtn" plain>登 录</el-button>
                    <span style="opacity: .02;">{{ apiUrl }}</span>
                </el-form>
            </div>
        </div>
    </div>
</template>
<script>
import { login } from "@/api/login"

export default {
    name: "login",
    data() {
        return {
            apiUrl:process.env.VUE_APP_L_BASE_API,
            loginForm: {
                password: "",
                username: "",
                loading:false
            }
        }
    },
    mounted() {

    },
    methods: {
        loginBtn() {
            this.loginForm.loading = true
            login(this.loginForm.username, this.loginForm.password, 1).then(res=>{
                this.loginForm.loading = false
            })
            .catch(err=>{
                console.log("登录错误",err)
                this.loginForm.loading = false
            })
        }
    }
}
</script>
<style scoped lang="css">
.el-form-item {
    margin-bottom: 30px !important;
}

.el-form {
    width: 80%;
}

.login-main {
    height: 100vh;
    width: 100vw;
    position: relative;
}

.login-bg {
    filter: blur(5px);
    z-index: -1;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    height: 100vh;
    width: 100vw;
}

.login-form {
    background-color: #fff;
    height: 50vh;
    width: 50vw;
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    margin: auto;
    z-index: 9;
    border-radius: 5px;
    display: flex;
}

.login-form-left {
    flex: 1;
    height: 100%;
}

.login-form-left img {
    height: 100%;
    width: 100%;
    border-radius: 5px 0 0 5px;
}

.login-form-right {
    flex: 1;
    height: 100%;
    border-radius: 0 5px 5px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.loginBtn {
    width: 100%;
}

.login-form-title {
    font-size: 20px;
    font-weight: bold;
    color: #333;
    margin-bottom: 30px;
}
</style>